home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / PASCSRC.ZIP / SUBRANGE.PAS < prev    next >
Pascal/Delphi Source File  |  1988-01-15  |  2KB  |  44 lines

  1.                                 (* Chapter 8 - Program 2 *)
  2. program Scaler_Operations;
  3.  
  4. type Days = (Mon,Tue,Wed,Thu,Fri,Sat,Sun);
  5.      Work = Mon..Fri;
  6.      Rest = Sat..Sun;
  7.  
  8. var  Day      : Days; (* This is any day of the week *)
  9.      Workday  : Work; (* These are the the working days *)
  10.      Weekend  : Rest; (* The two weekend days only *)
  11.      Index    : 1..12;
  12.      Alphabet : 'a'..'z';
  13.      Start    : 'a'..'e';
  14.  
  15. begin  (* main program *)
  16. (*  The following statements are commented out because they contain
  17.     various errors that will halt compilation.
  18.  
  19.    Workday := Sat;   Sat is not part of Workday's subrange.
  20.    Rest := Fri;      Fri is not part of Weekend's subrange.
  21.    Index := 13;      Index is only allowed to go up to 12,
  22.    Index := -1;        and down to 1.
  23.    Alphabet := 'A'   Alphabet, as defined, includes only the
  24.                        lower case alphabet.
  25.    Start := 'h'      h is not in the first five letters.
  26.  
  27.    End of commented out section.  *)
  28.  
  29.    Workday := Tue;
  30.    Weekend := Sat;
  31.    Day := Workday;
  32.    Day := Weekend;
  33.    Index := 3+2*2;
  34.    Start := 'd';
  35.    Alphabet := Start;
  36.                              (* since Alphabet is "d"    *)
  37.    Start := Succ(Alphabet);  (* Start will be 'e'        *)
  38.    Start := Pred(Alphabet);  (* Start will be 'c'        *)
  39.    Day := Wed;
  40.    Day := Succ(Day);  (* Day will now be 'Thu' *)
  41.    Day := Succ(Day);  (* Day will now be 'Fri' *)
  42.    Index := Ord(Day); (* Index will be 4 (Fri = 4) *)
  43. end. (* of main program *)
  44.